%%%-------------------------------------------------------------------
%%% @author kk
%%% @copyright (C) 2024, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 19. 7月 2024 17:30
%%%-------------------------------------------------------------------
-module(d13).
-author("kk").

%% API
%% 使用匿名函数对列表进行过滤，输出列表所有的奇数和偶数（可以使用API）
-export([filter/2]).

% 原始列表
%%List = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].
%%
%%% 过滤奇数
%%OddNumbers = lists:filter(fun(X) -> X rem 2 =/= 0 end, List).
%%
%%% 过滤偶数
%%EvenNumbers = lists:filter(fun(X) -> X rem 2 == 0 end, List).

filter(List, Type) ->
  case Type of
      even -> lists:filter(fun(X) -> X rem 2 == 0 end, List);
      odd -> lists:filter(fun(X) -> X rem 2 /= 0 end, List)
  end.